package chapter7.practice;

import java.util.Arrays;
import java.util.Scanner;

public class CaculateArray {
    public static void main(String[] args) {
        int[] arrays = new int[10];
        System.out.println("请依次输入10个数字:");
        Scanner scanner = new Scanner(System.in);
        int i = 0;
        while (i < 10) {
            int num = scanner.nextInt();
            arrays[i] = num;
            i++;
        }
        System.out.println("输入的10个数字为:" + Arrays.toString(arrays));
        int sum = 0;
        int max = arrays[0];
        int min = arrays[0];
        for (int j = 0; j < arrays.length; j++) {
            sum += arrays[j];
            if(arrays[j] > max) {
                max = arrays[j];
            }
            if(arrays[j] < min) {
                min = arrays[j];
            }
        }
        System.out.println("数组的平均值为：" + sum / arrays.length);
        System.out.println("数组中的最大值:" + max);
        System.out.println("数组中的最小值:" + min);
    }
}
